﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Cache
{
    public class RedisCacheManager : ICacheManager
    {
        public void Clear()
        {
            throw new NotImplementedException();
        }

        public T Get<T>(string key)
        {
            var help = new RedisHelper();
            return help.StringGet<T>(key);
        }

        public async Task<T> GetAsync<T>(string key)
        {
            var help = new RedisHelper();
            return await help.StringGetAsync<T>(key);
        }

        public bool IsSet(string key)
        {
            var help = new RedisHelper();
            return help.KeyExists(key);
        }

        public void Remove(string key)
        {
            var help = new RedisHelper();
            help.KeyDelete(key);
        }

        public void Set(string key, object data, TimeSpan cacheTime)
        {
            var help = new RedisHelper();
            help.StringSet(key, data, cacheTime);
        }

        public async Task SetAsync(string key, object data, TimeSpan cacheTime)
        {
            var help = new RedisHelper();
            await help.StringSetAsync(key, data, cacheTime);
        }
    }
}
